package edu.fhsu.csci468;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class ControlPanelServer implements Runnable
{
	
	private IControlPanelEventListener he;
	
	public ControlPanelServer(IControlPanelEventListener he)
	{
		this.he = he;
	}
	
	public void run()
	{

		try
		{
			ServerSocket s = new ServerSocket(Ports.CONTROL_PANEL_PORT);
			while(true)
			{
				Socket incoming = s.accept();
				ControlPanelThread controlPanel = new ControlPanelThread(incoming);
				(new Thread(controlPanel)).start();
				controlPanel.addControlPanelEventListener(he);
				he.addHandlerEventListener(controlPanel);
			}
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
		
	}
	
}
